package com.atguigu.design.pattern.v3;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @Author: shenhao
 * @CreatTime: 2024/11/8 21:41
 * @Version: 1.0
 */
public class FactoryV3 {
    // 定义策略map缓存
    private static Map<String,AbstractColaHandler> strategyMap=new ConcurrentHashMap<>();
    public static AbstractColaHandler getStrategy(String strategy){
        return strategyMap.get(strategy);
    }
    public static void register(String strategy,AbstractColaHandler handler){
        System.out.println("strategy = " + strategy + ", handler = " + handler);
        if (null == strategy || null == handler) {
            return;
        }
        strategyMap.put(strategy,handler);
    }
}
